import { createRouter, createWebHistory } from 'vue-router';

// 路由配置
const routes = [
  {
    path: '/',
    redirect: '/system/dict/category'
  },
  {
    path: '/system',
    component: () => import('../views/layout/Layout.vue'),
    children: [
      {
        path: 'dict/category',
        name: 'DictCategory',
        component: () => import('../views/system/dict/category.vue'),
        meta: { title: '字典管理', icon: 'el-icon-document' }
      }
    ]
  },
  {
    path: '/ai',
    component: () => import('../views/layout/Layout.vue'),
    children: [
      {
        path: 'chat',
        name: 'ChatAssistant',
        component: () => import('../views/ai/chat/index.vue'),
        meta: { title: '聊天助手', icon: 'el-icon-chat-dot-round' }
      },
      {
        path: 'chat/:sessionId',
        name: 'ChatSession',
        component: () => import('../views/ai/chat/index.vue'),
        meta: { title: '聊天会话', icon: 'el-icon-chat-dot-round' },
        props: true
      },
      {
        path: 'model',
        name: 'ModelManagement',
        component: () => import('../views/ai/model/index.vue'),
        meta: { title: '模型管理', icon: 'el-icon-box' }
      }
    ]
  },
  {
    path: '/mcp',
    component: () => import('../views/layout/Layout.vue'),
    children: [
      {
        path: 'service',
        name: 'McpServiceManagement',
        component: () => import('../views/mcp/service/index.vue'),
        meta: { title: 'MCP服务管理', icon: 'el-icon-connection' }
      }
    ]
  },
  {
    path: '/404',
    component: () => import('../views/error/404.vue'),
    hidden: true
  },
  // 未匹配的路由重定向到 404
  { path: '/:pathMatch(.*)*', redirect: '/404', hidden: true }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

export default router; 